<?php
include dirname(dirname(__FILE__)).'/admin-verify.php';
include dirname(__FILE__).'/functions.php';
?>
<!DOCTYPE html>
<html>
	<head>
		<?php include dirname(dirname(dirname(__FILE__))).'/include/common-header.php'; ?>
		<script type="text/javascript">
			$(document).ready(function() {
				<?php 
					if(isFrontOn())echo '$("#is_front_on").attr("checked","checked");';
					if(isTimerOn()) {
						echo '$("#is_timer_on").attr("checked","checked");';
					}
				?>
				$("#is_front_on").click(function() {
					var _is_on;
					if(document.getElementById("is_front_on").checked==true)_is_on=1;
					else _is_on=0;
					$.ajax({
						dataType:"text",
						url:'ajax/set-front-on.php',
						data:{is_on:_is_on},
						success:function(data) {
							if(data=='yes') {
								//yes
							} else {}
							if(_is_on==1)alert("前端页面已开放");
							else alert("前端页面已关闭");
						},
					});
				});
				$("#is_timer_on").click(function() {
					var _is_on;
					if(document.getElementById("is_timer_on").checked==true) {
						_is_on=1;
					} else  {
						_is_on=0;
					}
					$.ajax({
						dataType:"text",
						url:'ajax/set-timer-on.php',
						data:{is_on:_is_on},
						success:function(data) {
							if(data=='yes') {
								//yes
							} else {}
							if(_is_on==1) {
								alert("定时器已开启，现在将初始化计时器");
								// var token = <?php 
								// 	$token = 'zjsw';
								// 	echo '"'.md5($token).'"';
								// ?>;
								// var url = "start-timer.php?token="+token;
								// window.location=url;
							}
							else alert("定时器已关闭");
						},
					});
				});
			});
		</script>
	</head>
	<body>
		<div class="col-md-12">
			<div>
				<h3> 系统设置</h3>
			</div>
			<div>
			<form class="form-horizontal" role="form" method="post" action="">
				<div class="form-group">
				  	<label for="is_front_on" class="col-sm-2 control-label" >是否开放前端页面</label>
				    <div class="col-sm-10">
				     	<div class="checkbox">
					        <label>
					          <input type="checkbox" id="is_front_on" name="is_front_on" value="1">开放
					        </label>
				      	</div>
				   	</div>
				</div>
				<div class="form-group">
				  	<label for="is_timer_on" class="col-sm-2 control-label" >是否打开定时器<br>(若服务器重启则应重新勾选此项)</label>
				    <div class="col-sm-10">
				     	<div class="checkbox">
					        <label>
					          <input type="checkbox" id="is_timer_on" name="is_timer_on" value="1">打开
					        </label>
				      	</div>
				   	</div>
				</div>
			</form>
			</div>
		</div>
	</body>
</html>